echo"<br /><font color=red><B>This is a very simple challenge and if you solve it I will give you a flag. Good Luck!</B><br></font>";
if($_SERVER) { if ( preg_match('/shana|debu|aqua|cute|arg|code|flag|system|exec|passwd|ass|eval|sort|shell|ob|start|mail|\$|sou|show|cont|high|reverse|flip|rand|scan|chr|local|sess|id|source|arra|head|light|read|inc|info|bin|hex|oct|echo|print|pi|\.|\"|\'|log/i', $_SERVER['QUERY_STRING']) ) die('You seem to want to do something bad?'); }
if (!preg_match('/http|https/i', $_GET['file'])) { if (preg_match('/^aqua_is_cute$/', $_GET['debu']) && $_GET['debu'] !== 'aqua_is_cute') { $file = $_GET["file"]; echo"Neeeeee! Good Job!<br>"; } } elsedie('fxck you! What do you want to do ?!');
if($_REQUEST) { foreach($_REQUESTas$value) { if(preg_match('/[a-zA-Z]/i', $value)) die('fxck you! I hate English!'); } }
if (file_get_contents($file) !== 'debu_debu_aqua') die("Aqua is the cutest five-year-old child in the world! Isn't it ?<br>");
if ( sha1($shana) === sha1($passwd) && $shana != $passwd ){ extract($_GET["flag"]); echo"Very good! you know my password. But what is flag?<br>"; } else{ die("fxck you! you don't know my password! And you don't know sha1! why you come here!"); }
if(preg_match('/^[a-z0-9]*$/isD', $code) || preg_match('/fil|cat|more|tail|tac|less|head|nl|tailf|ass|eval|sort|shell|ob|start|mail|\`|\{|\%|x|\&|\$|\*|\||\<|\"|\'|\=|\?|sou|show|cont|high|reverse|flip|rand|scan|chr|local|sess|id|source|arra|head|light|print|echo|read|inc|flag|1f|info|bin|hex|oct|pi|con|rot|input|\.|log|\^/i', $arg) ) { die("<br />Neeeeee~! I have disabled all dangerous functions! You can't get my flag =w="); } else { include"flag.php"; $code('', $arg); } ?>
分析一下,有几个需要绕过的地方:
一:绕过 $_SERVER['QUERY_STRING']
1 2 3 4 5 6
if($_SERVER) { if ( preg_match('/shana|debu|aqua|cute|arg|code|flag|system|exec|passwd|ass|eval|sort|shell|ob|start|mail|\$|sou|show|cont|high|reverse|flip|rand|scan|chr|local|sess|id|source|arra|head|light|read|inc|info|bin|hex|oct|echo|print|pi|\.|\"|\'|log/i', $_SERVER['QUERY_STRING']) ) die('You seem to want to do something bad?'); }
首先我们需要知道 $_SERVER['QUERY_STRING'] 是什么,直白地说是:查询字符串
其实就是URL中?后面的东西,
例如:
1 2 3
localhost?a=12&b=34
$_SERVER['QUERY_STRING'] => a=12&b=34
这里需要绕过它,看似不可能,其实很简单
我们只需将url中的参数全部使用url编码即可绕过 ,
因为$_SERVER['QUERY_STRING']不会将参数自动进行url解码,
但是 $_GET[]会自动将参数进行url解码
综上:我们需要将url中所有存在关键字的参数全部urlencode即可绕过
二:绕过 /^aqua_is_cute$/
1 2 3 4
if (preg_match('/^aqua_is_cute$/', $_GET['debu']) && $_GET['debu'] !== 'aqua_is_cute') { $file = $_GET["file"]; echo"Neeeeee! Good Job!<br>"; }
if (file_get_contents($file) !== 'debu_debu_aqua') die("Aqua is the cutest five-year-old child in the world! Isn't it ?<br>");
这个是文件包含漏洞,我们可以使用data伪协议
1
file=data://text/plain,debu_debu_aqua
五:绕过 sha1()
1 2 3 4
if ( sha1($shana) === sha1($passwd) && $shana != $passwd ){ extract($_GET["flag"]); echo"Very good! you know my password. But what is flag?<br>"; }
sha1() 和 md5() 一样 ,当我们传入的参数为数组时就会返回 NULL, 即可绕过
1
shana[]=1&passwd[]=2
六:create_function()命令执行
1 2 3 4 5 6 7
if(preg_match('/^[a-z0-9]*$/isD', $code) || preg_match('/fil|cat|more|tail|tac|less|head|nl|tailf|ass|eval|sort|shell|ob|start|mail|\`|\{|\%|x|\&|\$|\*|\||\<|\"|\'|\=|\?|sou|show|cont|high|reverse|flip|rand|scan|chr|local|sess|id|source|arra|head|light|print|echo|read|inc|flag|1f|info|bin|hex|oct|pi|con|rot|input|\.|log|\^/i', $arg) ) { die("<br />Neeeeee~! I have disabled all dangerous functions! You can't get my flag =w="); } else { include"flag.php"; $code('', $arg); }